<h2>Critique Ratings</h2>
<div class="subsection">

  <h2>Photo</h2>
  <table width="100%" cellspacing="0" cellpadding="0" border="0">
    <tr valign="top">
      <td width="128">
        <b><%= @crit.photo.title %></b>
        <%if @crit.photo.created_at > 24.hours.ago -%><%= $new_img %><% end -%>&nbsp;(<%=@crit.photo.get_rate%>)<br>
        From <%= user_to_url @crit.photo.user %>
      </td>
      <td>
        <div class="thumbnail">
          <% url = url_for(:controller=>"gallery", :action=>"view", :id=>@crit.photo) %>
          <% image = image_tag(@crit.photo.to_url(:thumbnail), :class=>"photo", :id=>"photo_#{@crit.photo.id}", :title=>@crit.photo.description) %>
          <%= link_to image, url %><br>
        </div>
      </td>
    </tr>
  </table>

  <h2>Critique</h2>
  <div id="critiques_list">
    <table width="100%" cellspacing="0" cellpadding="0" border="0">
      <tr valign="top">
        <td width="128">
          <% @crit.rate.abs.times do %>
            <% if @crit.rate > 0 %>
              <%= $up_img %>
            <% else %>
              <%= $down_img %>
            <% end %>
          <% end %>
        </td>
        <td>
          From <%= user_to_url @crit.user %>&nbsp;&nbsp;<%= mail_to @crit.user.email, $mail_img %>
          &nbsp;&nbsp;on <%= @crit.updated_at.to_s(:long) %>
          <% if @crit.updated_at > 24.hours.ago %>
            <%= $new_img %>
          <% end %>
          <p>
          <%= @crit.content %><p>
        </td>
      </tr>
    </table>
  </div>

  <h2>Ratings</h2>
  <% namelist_up = ""
     namelist_down = ""
     final = 0
     final_up = 0
     final_down = 0
     @crit.critique_ratings(true).each do |rate|
       if rate.rate > 0
         namelist_up += user_to_url(rate.user)
         namelist_up += "&nbsp;&nbsp;&nbsp;&nbsp;"
         final_up += rate.rate
       end
       if rate.rate < 0
         namelist_down += user_to_url(rate.user)
         namelist_down += "&nbsp;&nbsp;&nbsp;&nbsp;"
         final_down += rate.rate
       end
       final += rate.rate
     end
  -%>

  <div id="critique_rating_up">
    <div class="rate_symbol">
      <%= final_up %>&nbsp;&nbsp;<%= $up_unq_img %>&nbsp;&nbsp;Helpful
    </div>
    <div class="rate_from">
      <% if final_up != 0 -%>
        <b>From</b><br><%= namelist_up %>
      <% else -%>
        Nobody has rated this critique helpful.
      <% end -%>
    </div>
  </div>
  
  <div id="critique_rating_down">
    <div class="rate_symbol">
      <%= final_down %>&nbsp;&nbsp;<%= $down_unq_img %>&nbsp;&nbsp;Unhelpful
    </div>
    <div class="rate_from">
      <% if final_down != 0 -%>
        <b>From</b><br><%= namelist_down %>
      <% else -%>
        Nobody has rated this critique unhelpful.
      <% end -%>
    </div>
  </div>

</div>

